import React, { useRef, useEffect, useState, } from 'react';
import Child from './Child';

const ForwardRef = () => {

  const [text, setText] = useState("子组件");
  const childRef = useRef(null);

  useEffect(() => {
    console.log(childRef && childRef.current);
    setText("子组件 hello world");
  }, []);

  return (
    <div>
      ForwardRef
      <Child ref={ childRef } text={ text } />
    </div>
  );
};

export default ForwardRef;
